const {
  cv
} = require('../utils');

const { runVideoFaceDetection } = require('./commons');

const classifier = new cv.CascadeClassifier(cv.HAAR_FRONTALFACE_DEFAULT);

const webcamPort = "rtsp://admin:HDMGLO@192.168.31.239:554";

function detectFaces(img) {
  // restrict minSize and scaleFactor for faster processing
  const options = {
    minSize: new cv.Size(200, 200),
    scaleFactor: 1.3,
    minNeighbors: 10
  };
  return classifier.detectMultiScaleGpu(img.bgrToGray(), options).objects;
}

runVideoFaceDetection(webcamPort, detectFaces);
